package com.deprice4u_client;

import android.app.SearchManager;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;

import com.deprice4u_client.products_on_sale.SearchResult;
import com.deprice4u_client.products_on_sale.SocialListViewActivity;

public class BackgroundActivity extends FragmentActivity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.background);

		// Get the intent, verify the action and get the query
		Intent intent = getIntent();
		if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
			String query = intent.getStringExtra(SearchManager.QUERY);

			Log.i("SM", "search :" + query);

			/*Intent it = new Intent(this, SearchResult.class);
			it.putExtra("queryKeyword", query);
			startActivity(it);*/
			//ListView에서 search 결과 받아옴
			

			MainTabsFragment tabs = (MainTabsFragment) getSupportFragmentManager().findFragmentById(R.id.tabs_fragment);
			tabs.isFromSearch = true;
			tabs.queryFromSearch = query;
			//tabs.updateTab(MainTabsFragment.TAB_ON_SALE, R.id.tab_on_sale);
//			tabs.updateTab(MainTabsFragment.TAB_ON_REQUEST, R.id.tab_on_request);

			
		}

	}

	public void makeNewRequestButtionClick(View view) {

		Intent makeNewRequestOfProduct = new Intent(view.getContext(),
				MakeNewRequestOfProduct.class);
		startActivity(makeNewRequestOfProduct);
	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			moveTaskToBack(true);
			finish();
			android.os.Process.killProcess(android.os.Process.myPid());
		}
		return super.onKeyDown(keyCode, event);
	}
}
